<?php


namespace App\backend\services;

use App\backend\models\MemberLevelModel;

class MemberLevelServices
{

    /**
     * 添加/编辑
     *
     */
    public static function levelModify($params)
    {
        if (empty($params) && $params == false) {
            return [];
        }

        $id = isset($params['level_id']) && !empty($params['level_id']) ? $params['level_id'] : 0;unset($params['level_id']);

        if ($id) {
            $params['updated_at'] = time();
            $result = MemberLevelModel::where('id',$id)->update($params);
        } else {
            $params['created_at'] = time();
            $result = MemberLevelModel::insertGetId($params);
        }

        return $result?$result:'';
    }

    /**
     * 删除
     */
    public static function levelDelete($params)
    {
        $id = $params['level_id'];
        if (empty($id)) {
            return [];
        }

        return MemberLevelModel::where('id',$id)->delete();


    }

}
